package com.ljye.jg.ljye.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ljye.jg.ljye.R;
import com.ljye.jg.ljye.adapter.ViewPagerAdapter;
import com.ljye.jg.ljye.layout.NavitationLayout;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by Administrator on 2016/9/29.
 */
public class Fragment_message extends Fragment {

    private View view;
    private String[] titles1 = new String[]{"系统消息", "联系人"};
    private NavitationLayout navitationLayout;//title
    private ViewPager viewPager1;//viewpager
    private ViewPagerAdapter viewPagerAdapter;//适配器
    private List<Fragment> fragments;//集合
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (null == view) {
            view = inflater.inflate(R.layout.fragment_message, null);
            initView();
            initPager();
        }
        return view;
    }

    private void initPager() {
        fragments = new ArrayList<>();
        fragments.add(new Fragment_message_1());
        fragments.add(new Fragment_message_2());
        viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager(), fragments);
        viewPager1.setAdapter(viewPagerAdapter);
        //上下文        标题栏    ViewPager 未选中字体颜色         选中字体颜色          未选中字体大小 选中字体大小 当前viewpager的位置  导航条的边距 是否开启滑动
        navitationLayout.setViewPager(getActivity(), titles1, viewPager1, R.color.black, R.color.activity_title_color, 13, 13, 0, 40, true);
        navitationLayout.setBgLine(getActivity(), 1, R.color.white); //导航背景色
        navitationLayout.setNavLine(getActivity(), 2, R.color.activity_title_color, 0);//导航条颜色
    }


    private void initView() {
        viewPager1 = (ViewPager) view.findViewById(R.id.viewpager1);
        navitationLayout = (NavitationLayout) view.findViewById(R.id.bar1);
    }

}
